package dao

import (
	"vtrip/internal/model"
)

func (d *Dao) FindAllItinerary(userId, pageOffset, pageSize int) ([]*model.ItineraryPart, error) {
	itinerary := &model.Itinerary{
		UserId: userId,
	}
	return itinerary.All(d.engine, pageOffset, pageSize)
}

func (d *Dao) CreateItinerary(title, slogan, coverUrl, scheduleDetail, hotelDetail string,
	startDate, endDate, typeId, userId int) error {

	itinerary := &model.Itinerary{
		Title:          title,
		Slogan:         slogan,
		CoverUrl:       coverUrl,
		StartDate:      startDate,
		EndDate:        endDate,
		TypeId:         typeId,
		ScheduleDetail: scheduleDetail,
		HotelDetail:    hotelDetail,
		UserId:         userId,
	}

	return itinerary.Create(d.engine)
}

func (d *Dao) GetItineraryDetail(itineraryId int) (*model.ItineraryDetail, error) {
	itinerary := &model.Itinerary{
		Model: &model.Model{
			ID: itineraryId,
		},
	}

	return itinerary.GetDetail(d.engine)
}
